package com.example.designPatterns.state;

import com.example.designPatterns.state.impl.WaitDeliverOrderState;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title: OrderStateFactory
 * @Description: TODO
 * @Date 2021/9/30 10:17
 */
public class OrderStateFactory {

    private static Map<String, AbstractOrderState> shareStateMap = new HashMap<>();


    static {
        WaitDeliverOrderState waitDeliverOrderState = new WaitDeliverOrderState();
        shareStateMap.put(waitDeliverOrderState.orderState().name(), waitDeliverOrderState);
    }

    //读取状态
    public static AbstractOrderState getState(OrderStateEnum key) {
        return shareStateMap.get(key.name());
    }
}
